home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / pine / osdep / print.win < prev    next >
Text File  |  1995-07-14  |  4KB  |  156 lines

  1. #line 2 "osdep/print.win"
  2. /*======================================================================
  3.     print routines
  4.    
  5.     Functions having to do with printing on paper and forking of spoolers
  6.  
  7.     In general one calls open_printer() to start printing. One of
  8.     the little print functions to send a line or string, and then
  9.     call print_end() when complete. This takes care of forking off a spooler
  10.     and piping the stuff down it. No handles or anything here because there's
  11.     only one printer open at a time.
  12.  
  13.  ====*/
  14.  
  15.  
  16. /*----------------------------------------------------------------------
  17.        Open the printer
  18.  
  19.   Args: desc --Description of item to print. Should have on tailing blank.
  20.  
  21. This does most of the work of popen so we can save the standard output of the
  22. command we execute and send it back to the user.
  23.   ----*/
  24. int
  25. open_printer(desc)
  26.      char *desc;
  27. {
  28.     unsigned short status;
  29.  
  30.     if (status = mswin_print_ready (0, desc)) {
  31.         q_status_message1(SM_ORDER | SM_DING, 3, 4,
  32.               "Error starting print job: %s",
  33.               mswin_print_error(status));
  34.         return(-1);
  35.     }
  36.  
  37.     q_status_message(SM_ORDER, 0, 9, "Printing to windows printer...");
  38.     display_message('x');
  39.  
  40.     /* init print control structure */
  41.     ps_global->print = (PRINT_S *)fs_get(sizeof(PRINT_S));
  42.     memset(ps_global->print, 0, sizeof(PRINT_S));
  43.  
  44.     ps_global->print->err = 0;
  45.     return(0);
  46. }
  47.  
  48.  
  49.  
  50. /*----------------------------------------------------------------------
  51.      Close printer
  52.   
  53.   If we're piping to a spooler close down the pipe and wait for the process
  54. to finish. If we're sending to an attached printer send the escape sequence.
  55. Also let the user know the result of the print
  56.  ----*/
  57. void
  58. close_printer()
  59. {
  60.     mswin_print_done();
  61.  
  62.     fs_give((void **)&ps_global->print);
  63.  
  64.     q_status_message(SM_ASYNC, 0, 3, "Print command completed");
  65.     display_message('x');
  66. }
  67.  
  68.  
  69.  
  70. /*----------------------------------------------------------------------
  71.      Print a single character
  72.  
  73.   Args: c -- char to print
  74.   Returns: 1 on success, 0 on ps_global->print->err
  75.  ----*/
  76. int
  77. print_char(c)
  78.     int c;
  79. {
  80.     if(!ps_global->print->err
  81.        && (ps_global->print->err = mswin_print_char (c)))
  82.       q_status_message1(SM_ORDER, 0, 9, "Print cancelled: %s",
  83.              mswin_print_error((unsigned short)ps_global->print->err));
  84.  
  85.     return(!ps_global->print->err);
  86. }
  87.  
  88.  
  89.  
  90. /*----------------------------------------------------------------------
  91.      Send a line of text to the printer
  92.  
  93.   Args:  line -- Text to print
  94.  
  95.   ----*/
  96. void
  97. print_text(line)
  98.     char *line;
  99. {
  100.     if(!ps_global->print->err
  101.        && (ps_global->print->err = mswin_print_text(line)))
  102.       q_status_message1(SM_ORDER, 0, 9, "Print cancelled: %s",
  103.              mswin_print_error((unsigned short)ps_global->print->err));
  104. }
  105.  
  106.  
  107.  
  108. /*----------------------------------------------------------------------
  109.       printf style formatting with one arg for printer
  110.  
  111.  Args: line -- The printf control string
  112.        a1   -- The 1st argument for printf
  113.  ----*/
  114. void
  115. print_text1(line, a1)
  116.     char *line, *a1;
  117. {
  118.     sprintf(tmp_20k_buf, line, a1);
  119.     print_text(tmp_20k_buf);
  120. }
  121.  
  122.  
  123.  
  124. /*----------------------------------------------------------------------
  125.       printf style formatting with one arg for printer
  126.  
  127.  Args: line -- The printf control string
  128.        a1   -- The 1st argument for printf
  129.        a2   -- The 2nd argument for printf
  130.  ----*/
  131. void
  132. print_text2(line, a1, a2)
  133.     char *line, *a1, *a2;
  134. {
  135.     sprintf(tmp_20k_buf, line, a1, a2);
  136.     print_text(tmp_20k_buf);
  137. }
  138.  
  139.  
  140.  
  141. /*----------------------------------------------------------------------
  142.       printf style formatting with one arg for printer
  143.  
  144.  Args: line -- The printf control string
  145.        a1   -- The 1st argument for printf
  146.        a2   -- The 2nd argument for printf
  147.        a3   -- The 3rd argument for printf
  148.  ----*/
  149. void
  150. print_text3(line, a1, a2, a3)
  151.     char *line, *a1, *a2, *a3;
  152. {
  153.     sprintf(tmp_20k_buf, line, a1, a2, a3);
  154.     print_text(tmp_20k_buf);
  155. }
  156.